/*
  MinCC - Minimalist Compiler Collection
  Copyright (C) 2009 Scott Lawrence

  MinCC is free software: you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  MinCC is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
  License for more details.

  You should have received a copy of the GNU General Public License
  along with mincc.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef ERROR_HPP
#define ERROR_HPP

#define START_ERRORS() struct MCC_error_t errs[]={
#define DECLARE_ERROR(x,y) {x,y},
#define END_ERRORS {-1,""}};


#define ERROR error(__LINE__,__FUNCTION__)
#define IERROR(x) error(__LINE__,__FUNCTION__,x) 
#define IERRORT(x,t) error(__LINE__,__FUNCTION__,x,t) 

#define FATAL fatal(__LINE__,__FUNCTION__)
#define IFATAL(x) fatal(__LINE__,__FUNCTION__,x)
#define IFATALT(x,t) fatal(__LINE__,__FUNCTION__,x,t)

struct MCC_error_t {
    int id;
    const char *description;
};

extern struct MCC_error_t errs[];

const char *getErrorDescription();

void error(int,const char *);
void error(int,const char *,int);
void error(int,const char *,int,const char *);

void fatal(int,const char *);
void fatal(int,const char *,int);
void fatal(int,const char *,int,const char *);

void initErrors();

#endif
